package com.wangsd.web.face.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Data
@Entity
@Table(name = "member")
@ApiModel(value = "会员管理", description = "会员管理")
public class Member implements Serializable {
    @ApiModelProperty(value = "商户id")
    private Long merchantId;
    @ApiModelProperty(value = "商户等级id")
    private Long memberLevelId;

    @ApiModelProperty(value = "会员卡卡号")
    private String cardNo;

    @ApiModelProperty(value = "用户手机号")
    private String mobile;

    @ApiModelProperty(value = "微信用户id")
    private String openId;
    @ApiModelProperty(value = "微信用户子商户id")
    private String subOpenId;

    @ApiModelProperty(value = "微信小程序openid")
    private String miniOpenId;

    @ApiModelProperty(value = "支付宝用户id")
    private String userId;

    @ApiModelProperty(value = "账户余额")
    @Column(name = "total_balances",columnDefinition = "bigint(20) default 0 not null")
    private Long totalBalances;

    @ApiModelProperty(value = "积分")
    @Column(name = "total_integral",columnDefinition = "bigint(11) default 0 not null")
    private Long totalIntegral;

    @ApiModelProperty(value = "是否是会员")
    @Column(name = "status",columnDefinition = "int(1) default 0 not null")
    private Integer status;

    @ApiModelProperty(value = "昵称")
    private String nickName;

    @ApiModelProperty(value = "性别 1男，2女")
    private String gender;

    @ApiModelProperty(value = "微信头像")
    private String avatarUrl;

    @ApiModelProperty(value = "激活时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date useTime;

    @ApiModelProperty(value = "生日")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    /**
     * 以下是通用字段
     */
    @Id
    @TableId(type = IdType.AUTO)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private Date createdTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updatedTime;

    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private Integer deleted;

    @ApiModelProperty(value = "检索标识")
    private String code;


    /**
     * 扩展字段
     */
    @ApiModelProperty(value = "商户名称")
    @Transient
    @TableField(exist = false)
    private String merhantName;

    @ApiModelProperty(value = "代理商名称")
    @Transient
    @TableField(exist = false)
    private String agentName;

    @ApiModelProperty(value = "服务商名称")
    @Transient
    @TableField(exist = false)
    private String businessName;


    @Transient
    @TableField(exist = false)
    private String sessionKey;

    /**
     * 商户对象信息
     */
    @ApiModelProperty(value = "商户对象信息")
    @Transient
    @TableField(exist = false)
    private Merchant merchant;

    /**
     * 会员等级信息
     */
    @ApiModelProperty(value = "会员等级信息")
    @Transient
    @TableField(exist = false)
    private MemberLevel memberLevel;

    /**
     * unionId
     */
    @ApiModelProperty(value = "unionId")
    @Transient
    @TableField(exist = false)
    private String unionId;
}
